﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Leasson6 : MonoBehaviour
{
    public Rect groupPos;
    public Texture tex;

    public Rect scPos;
    public Vector2 nowPos;
    public Rect showPos;
    public string[] bars = new string[] {"刀","剑","木头","石头","草莓","铜矿石","银矿石","金矿石"};
    private void OnGUI()
    {
        #region 知识一 分组
        // 用于指控制控件位置
        // 可以理解为 包裹着的控件加一个父对象
        // 可以通过控制分组来控制包裹控件的位置
        GUI.BeginGroup(groupPos);
        GUI.Button(new Rect(0,0,100,50), "测试按钮");
        GUI.Label(new Rect(0, 60, 100, 20), "Label信息");
        GUI.DrawTexture(new Rect(0,100,100,100), tex);
        GUI.EndGroup();

        #endregion

        #region 滚动列表
        nowPos = GUI.BeginScrollView(scPos, nowPos, showPos);
        GUI.Toolbar(new Rect(0, 0,500,50), 0, bars);
        GUI.Toolbar(new Rect(0, 60, 500, 50), 0, bars);
        GUI.Toolbar(new Rect(0, 120, 500, 50), 0, bars);
        GUI.Toolbar(new Rect(0, 180, 500, 50), 0, bars);
        GUI.EndScrollView();
        #endregion
    }
}
